From 75e26dafe4a9a82bef3d64f9ed626eff44683201 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Tue, 6 Dec 2005 00:38:08 +0000 Subject: [PATCH] Update GUI to internal release 0.2.2.20. --- gpsbabel/win32/gui-2/GPSBabelGUI.dpr | 5 +- gpsbabel/win32/gui-2/main.dfm | Bin 36702 -> 37243 bytes gpsbabel/win32/gui-2/main.pas | 302 ++++++++++++++++++++++----- 3 files changed, 255 insertions(+), 52 deletions(-) diff --git a/gpsbabel/win32/gui-2/GPSBabelGUI.dpr b/gpsbabel/win32/gui-2/GPSBabelGUI.dpr index dd78f1bde..467528f59 100644 --- a/gpsbabel/win32/gui-2/GPSBabelGUI.dpr +++ b/gpsbabel/win32/gui-2/GPSBabelGUI.dpr @@ -19,6 +19,8 @@ program GPSBabelGUI; uses gnugettext in 'gnugettext.pas', + gnugettextDx in 'gnugettextDx.pas', + delphi in 'delphi.pas', Windows, SysUtils, classes, @@ -29,7 +31,8 @@ uses filter in 'filter.pas' {frmFilter}, about in 'about.pas' {frmAbout}, readme in 'readme.pas' {frmReadme}, - options in 'options.pas' {frmOptions}; + options in 'options.pas' {frmOptions}, + select in 'select.pas' {frmSelect}; {$R *.RES} diff --git a/gpsbabel/win32/gui-2/main.dfm b/gpsbabel/win32/gui-2/main.dfm index 88c81da4d434c482f55634d2cf45f09f7d5d9461..1fd4caa343f705d11d99d0e9452c1da203252553 100644 GIT binary patch delta 728 zcmaJ<&ubGw7~T9Zn>58Fm}n~oSEOPNmbQmNk2Ou{qREDC=uw!R{gMpb%q%mr`B4NB z52dvf%H9R_FOb~y;=!x_2|aldJbDt;-K;jYptt$H_uhQ(do!mm;@@Az^FL>l*5-D- zzOFZvr93$~$(J*aV~G}X6Sre;R*$lUv_Y#~L_45f!In;4&%alkAAibzoxM4Qir6wd z>3VVl`UFEH7{8lCv*jC2&M*j}4baGCgi4LjHsd`c38Vhv!prOPe;Ay363)S=3s0x8 z-)J(ZRmy^bH_*fb8F?O z)H<%PkOj^n7JcomM+s&&R5Avw4FLyM)T;<@5(lR0(&2|km%`SvT19TSK`IrYYK@{` zterkHpk!Kgpq?(FSEzD864*o`f@v$MbsVbI+=U5>|MBokrDTq%?1CVBpowrhih3ZD zTS0oMrrx29|L*&rpDz_{5SWw6-5TQ>WfH{r)=?v#IrHMP&ilY1i3rz%0 delta 237 zcmeypi0R%uCV~H43?XhozP^s0ehdZzKK&B~WI2r)nM3jmn5QyqH0$Bs{DAu>&*mQz zi9AAro_WbRr75Wj<%yLA`I&ho#gofa7xMGLgp2Y^OHzv`8>%%T#7c@1le3FApHcgl zB+l-dmzb23n!>>moRMEt;#^w7;(vgFVe-Sy%*hu!L?(xJ$xVLRwR 0) then Caption := Format('%s (%s)', [Caption, _('Special release')]); - memoOutput.Lines.Clear; - - FCaps := TCapabilities.Create; - FOpts := TOptions.Create(FCaps); - - OpenDialog.InitialDir := ReadProfile(OpenDialog.Tag); - SaveDialog.InitialDir := ReadProfile(SaveDialog.Tag); - - if not ComboBoxSelect(cbInputDevice, ReadProfile(cbInputDevice.Tag)) then - cbInputDevice.ItemIndex := 0; - - if not ComboBoxSelect(cbOutputDevice, ReadProfile(cbOutputDevice.Tag)) then - cbOutputDevice.ItemIndex := 0; - FixAlign(sbOpenFile, 8); FixAlign(sbSaveFile, 8); FixAlign(edInputFile, 8, sbOpenFile); @@ -275,6 +266,44 @@ begin FixAlign(btnProcess, 8); FixAlign(btnFilter, 16, btnProcess); + gbInput.Caption := '>>> ' + _('Input'); + gbOutput.Caption := '<<< ' + _('Output'); + chbInputDevice.Caption := '[' + chbInputDevice.Caption + ']'; + chbOutputDevice.Caption := '[' + chbOutputDevice.Caption + ']'; + + acOptionsSourceFormat.Caption := _('Input') + ': ' + FFmtIn; + acOptionsTargetFormat.Caption := _('Output') + ': ' + FFmtOut; + + btnInputOpts.Caption := ''; + btnOutputOpts.Caption := ''; +end; + +procedure TfrmMain.FormCreate(Sender: TObject); +begin + MakeFirstTranslation(Self); + + FFirstShow := True; + + TP_Ignore(mnuDebug, 'mnuDebug'); +{$IFOPT D-} + mnuDebug.Visible := False; +{$ENDIF} + LoadLanguages; + + memoOutput.Lines.Clear; + + FCaps := TCapabilities.Create; + FOpts := TOptions.Create(FCaps); + + OpenDialog.InitialDir := ReadProfile(OpenDialog.Tag); + SaveDialog.InitialDir := ReadProfile(SaveDialog.Tag); + + if not ComboBoxSelect(cbInputDevice, ReadProfile(cbInputDevice.Tag)) then + cbInputDevice.ItemIndex := 0; + + if not ComboBoxSelect(cbOutputDevice, ReadProfile(cbOutputDevice.Tag)) then + cbOutputDevice.ItemIndex := 0; + edInputFile.Text := ReadProfile(edInputFile.Tag); cbInputLang.ItemIndex := 0; @@ -282,11 +311,8 @@ begin Application.OnIdle := Self.DoOnIdle; - gbInput.Caption := '>>> ' + _('Input'); - gbOutput.Caption := '<<< ' + _('Output'); - - chbInputDevice.Caption := '[' + chbInputDevice.Caption + ']'; - chbOutputDevice.Caption := '[' + chbOutputDevice.Caption + ']'; + RefreshDesign(True); + HandleParams; end; procedure TfrmMain.LoadLanguages; @@ -294,7 +320,8 @@ begin FLang := TStringList.Create; DefaultInstance.GetListOfLanguages('default', FLang); - if (FLang.IndexOf('en') < 0) then FLang.Add('en'); + if (FLang.IndexOf('en') < 0) then + FLang.Add('en'); acFileChangeLanguage.Visible := (FLang.Count > 1); end; @@ -404,12 +431,14 @@ begin if IsInput then begin + FFmtIn := Format; wptInputOK.Enabled := (caps and 1 <> 0); trkInputOK.Enabled := (caps and 4 <> 0); rteInputOK.Enabled := (caps and 16 <> 0); end else begin + FFmtOut := Format; wptOutputOK.Enabled := (caps and 2 <> 0); trkOutputOK.Enabled := (caps and 8 <> 0); rteOutputOK.Enabled := (caps and 32 <> 0); @@ -461,6 +490,9 @@ end; procedure TfrmMain.CheckInput; begin acConvert.Enabled := + (cbWaypoints.Checked or cbRoutes.Checked or cbTracks.Checked) + and + ( ((chbInputDevice.Checked and (cbInputDevice.Text <> '') and (cbInputFormatDevice.Text <> '')) @@ -475,7 +507,8 @@ begin or (not(chbOutputDevice.Checked) and (edOutputFile.Text <> '') and - (cbOutputFormat.Text <> ''))); + (cbOutputFormat.Text <> ''))) + ); end; procedure TfrmMain.edOutputFileChange(Sender: TObject); @@ -638,9 +671,9 @@ begin s := 'gpsbabel.exe ' + cmdline; AddToOutput(s); + CSave := Cursor; list := TStringList.Create; try - CSave := Cursor; Cursor := crHourGlass; Application.ProcessMessages; Sleep(50); @@ -793,6 +826,7 @@ begin cbInputDevice.Visible := True; cbInputFormatDevice.Visible := True; lbInputFile.Caption := _('Port'); + FFmtIn := cbInputFormatDevice.Text; end else begin @@ -803,7 +837,10 @@ begin cbInputDevice.Visible := False; sbOpenFile.Visible := True; lbInputFile.Caption := _('File'); + FFmtIn := cbInputFormat.Text; end; + acOptionsSourceFormat.Caption := _('Input') + ': ' + FFmtIn; + acOptionsSourceFormat.Enabled := (FOpts.FormatOpts(FFmtIn) <> nil); CheckInput; end; @@ -844,6 +881,7 @@ begin sbSaveFile.Visible := False; cbOutputFormat.Visible := False; lbOutputFile.Caption := _('Port'); + FFmtOut := cbOutputFormatDevice.Text; end else begin @@ -853,12 +891,17 @@ begin cbOutputDevice.Visible := False; cbOutputFormatDevice.Visible := False; lbOutputFile.Caption := _('File'); + FFmtOut := cbOutputFormat.Text; end; + acOptionsTargetFormat.Caption := _('Output') + ': ' + FFmtOut; + acOptionsTargetFormat.Enabled := (FOpts.FormatOpts(FFmtOut) <> nil); CheckInput; end; procedure TfrmMain.acHelpReadmeExecute(Sender: TObject); begin + if (frmReadme = nil) then + Application.CreateForm(TfrmReadme, frmReadme); frmReadme.ShowModal; end; @@ -1021,10 +1064,12 @@ begin HistoryChanged(edOutputFile); edOutputFile.Text := '-'; edOutputFile.Enabled := False; + edOutputFile.Color := clInactiveBorder; sbSaveFile.Enabled := False; end else begin + edOutputFile.Color := edInputFile.Color; chbOutputDevice.Enabled := True; edOutputFile.Enabled := True; HistoryChanged(edOutputFile, True); @@ -1033,6 +1078,24 @@ begin CheckInput; end; +procedure TfrmMain.HandleParams; +var + i: Integer; + s: string; +begin + for i := 1 to ParamCount do + begin + s := ParamStr(i); + if (i = 0) then + edInputFile.Text := s + else begin + if (i = 1) then + edInputFile.Items.Add(edInputFile.Text); + edInputFile.Items.Add(s); + end; + end; +end; + procedure TfrmMain.HistoryChanged(Box: TComboBox; Swap: Boolean); var index: Integer; @@ -1057,16 +1120,22 @@ var i, j, len: Integer; s: string; f: TFileStream; + + procedure WriteLn(Str: string); + begin + Str := Str + #13#10; + f.Write(PChar(Str)^, Length(Str)); + end; + begin l := TStringList.Create; try FOpts.DebugGetHints(l); - f := TFileStream.Create('options\options.inc', fmCreate); + f := TFileStream.Create('..\gpsbabel.po', fmCreate); try - s := '{gnugetext: scan-all text-domain=''options''}'#13#10#13#10; - f.Write(PChar(s)^, Length(s)); - s := 'const'#13#10; - f.Write(PChar(s)^, Length(s)); + WriteLn('msgid ""'); + WriteLn('msgstr ""'); + WriteLn(''); for i := 0 to l.Count - 1 do begin @@ -1074,17 +1143,15 @@ begin len := Length(s); for j := len downto 1 do begin - if (s[j] = '''') then + if (s[j] = '"') then begin - Insert('''', s, j); + Insert('\', s, j); end; end; - s := Format('resourcestring option_%d=''%s'';'#13#10, [i, s]); - f.Write(PChar(s)^, Length(s)); + WriteLn('msgid "' + s + '"'); + WriteLn('msgstr ""'); + WriteLn(''); end; - - s := #13#10'{gnugettext: reset }'#13#10; - f.Write(PChar(s)^, Length(s)); finally f.Free; end; @@ -1095,15 +1162,148 @@ end; procedure TfrmMain.acFileChangeLanguageExecute(Sender: TObject); var - i: Integer; - s: string; + lang: string; + form: TForm; + title: string; begin - for i := 0 to FLang.Count - 1 do + Title := _('Choose language') + ' ' + _('for GUIBabelGUI'); + if SelectLanguage(Title, FLang, lang) and + (CompareText(lang, Copy(GetCurrentLanguage, 1, 2)) <> 0) then begin - s := FLang.Strings[i]; - if (s = '') then - Halt(1); + StoreProfile(11, lang); + UseLanguage(lang); + RefreshDesign; + form := frmFilter; + frmFilter := nil; + if (Form <> nil) then Form.Release; + form := frmReadme; + frmReadme := nil; + if (Form <> nil) then Form.Release; + form := frmAbout; + frmAbout := nil; + if (Form <> nil) then Form.Release; end; end; +procedure TfrmMain.acFileExportCSVExecute(Sender: TObject); +const + init_dir: string = ''; + file_name: string = 'gpsbabel.csv'; +var + i, j, len: Integer; + s, lang, curr_lang: string; + o: POption; + f: TFileStream; + l: TStrings; + + function _translate(const Domain, MsgID: string): WideString; + var + i: Integer; + tmp: WideString; + boo: Boolean; + begin + tmp := MsgID; + Result := dgettext(Domain, tmp); + if (Result = tmp) then + Result := _(MsgID); + if (Result = tmp) then + Result := '' + else begin + boo := False; + i := Length(Result); + while (i >= 1) do + begin + if (Result[i] = '"') then + begin + Insert('"', Result, i); + boo := True; + end; + Dec(i); + end; + if (boo) then + begin + memoOutput.Lines.Add('Warning: ''"'' found in translation!'); + memoOutput.Lines.Add(Result); + end; + end; + end; + + procedure _line(const Prefix, MsgID: string); + begin + UniWriteLn(f, Prefix + ',"' + MsgID + '","' + + _translate(GPSBabel_Domain, MsgID) + '"'); + end; + +begin + if not SelectLanguage( + _('Choose language') + ' ' + _('for export'), + FLang, lang) then Exit; + + if (sdOptional.InitialDir = '') then + GetDir(0, init_dir); + + sdOptional.InitialDir := init_dir; + sdOptional.FileName := file_name; + + if not(sdOptional.Execute) then Exit; + + init_dir := sdOptional.InitialDir; + file_name := sdOptional.FileName; + + curr_lang := GetCurrentLanguage; + try + + UseLanguage(lang); + + f := TFileStream.Create(sdOptional.FileName, fmCreate); + try + + UniWriteLn(f, Format('code,en,%s', [lang])); + + _line('options:-w', 'Process waypoint information'); + _line('options:-r', 'Process route information'); + _line('options:-t', 'Process track information'); + + _line('options:-s', 'Synthesize shortnames'); + _line('options:-c', 'Character set for next operation'); + + + for i := 0 to FCaps.Count - 1 do + begin + if not FCaps.IsFile(i) then Continue; + + s := FCaps.GetDescr(i); + UniWrite(f, Format('format:%s,', [FCaps.GetName(s)])); + UniWriteLn(f, '"' + s + '","' + _translate(GPSBabel_Domain, s) + '"'); + + l := FOpts.FormatOpts(s); + if (l = nil) then Continue; + + for j := 0 to l.Count - 1 do + begin + o := Pointer(l.Objects[j]); + UniWrite(f, Format('format:%s:%s,', [o.format, o.name])); + UniWriteLn(f, '"' + o.hint + '","' + _translate(GPSBabel_Domain, o.hint) + '"'); + end; + end; + + finally + f.Free; + end; + + finally + UseLanguage(curr_lang); + end; +end; + +procedure TfrmMain.cbOutputDeviceChange(Sender: TObject); +begin + CheckInput; +end; + +procedure TfrmMain.cbInputDeviceChange(Sender: TObject); +begin + CheckInput; +end; + end. -- 2.30.2